
/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_Studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "stdafx.h"
#include "PBF解算数据.h"



S_外力数据::S_外力数据(S_设备环境& ctx) {
	m_方向力 = f_buf_create板载缓存(ctx, sizeof(vec3), E_板载缓存类型::e_UBO);
}

void S_外力数据::f_resize(uint64 count, uint8 邻接最大数量) {
	f_buf_resize(m_方向力, count);
}







S_vk邻接数据::S_vk邻接数据(S_设备环境& ctx) {
	m_排序索引桶A = f_buf_create板载缓存(ctx, sizeof(uvec2), E_板载缓存类型::e_SSBO);
	m_排序索引桶B = f_buf_create板载缓存(ctx, sizeof(uvec2), E_板载缓存类型::e_SSBO);
	m_排序桶元素数量 = f_buf_create板载缓存(ctx, sizeof(uvec2), E_板载缓存类型::e_SSBO);
	m_排序桶元素偏移 = f_buf_create板载缓存(ctx, sizeof(uvec2), E_板载缓存类型::e_SSBO);

	m_合并元素参数 = f_buf_create板载缓存(ctx, sizeof(uvec2), E_板载缓存类型::e_UBO);
	m_索引体素 = f_buf_create板载缓存(ctx, sizeof(uint32), E_板载缓存类型::e_SSBO);


}

void S_vk邻接数据::f_resize(uint64 count, uint16 分段数) {
	f_buf_resize(m_排序索引桶A, count);
	f_buf_resize(m_排序索引桶B, count);
	f_buf_resize(m_排序桶元素数量, count);
	f_buf_resize(m_排序桶元素偏移, count);

	f_buf_resize(m_合并元素参数, count);
	f_buf_resize(m_索引体素, 512 * 512 * 512);

}








S_坐标数据::S_坐标数据(S_设备环境& ctx) {
	m_坐标 = f_buf_create板载缓存(ctx, sizeof(vec3), E_板载缓存类型::e_SSBO);
	m_速度 = f_buf_create板载缓存(ctx, sizeof(vec3), E_板载缓存类型::e_SSBO);
	m_块量 = f_buf_create板载缓存(ctx, sizeof(float32), E_板载缓存类型::e_SSBO);
	m_邻接 = f_buf_create板载缓存(ctx, sizeof(uint32), E_板载缓存类型::e_SSBO);

	m_坐标_Old = f_buf_create板载缓存(ctx, sizeof(vec3), E_板载缓存类型::e_SSBO);
	m_坐标_上一次最终 = f_buf_create板载缓存(ctx, sizeof(vec3), E_板载缓存类型::e_SSBO);

	m_属性 = f_buf_create板载缓存(ctx, sizeof(S_PBF计算属性), E_板载缓存类型::e_UBO);

	m_外力数据 = new S_外力数据(ctx);
	m_坐标邻接 = new S_vk邻接数据(ctx);
}

void S_坐标数据::f_resize(uint64 count, uint8 邻接最大数量) {
	f_buf_resize(m_坐标, count);
	f_buf_resize(m_速度, count);
	f_buf_resize(m_块量, count);

	f_buf_resize(m_邻接, count * 邻接最大数量);

	f_buf_resize(m_坐标_Old,		count);
	f_buf_resize(m_坐标_上一次最终,	count);

	m_外力数据->f_resize(count, 邻接最大数量);
	m_坐标邻接->f_resize(count, 1024);
}

void S_坐标数据::f_set属性(const S_PBF计算属性& data) {
	f_buf_set(m_属性, 0, data);
}




















